#!/usr/bin/env python
# -*- coding: UTF-8 -*-
########################################################################
#
# This file is part of oBoxKit.
# 
#     oBoxKit is free software: you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
# 
#     oBoxKit is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
# 
#     You should have received a copy of the GNU General Public License
#     along with oBoxKit.  If not, see <http://www.gnu.org/licenses/>.
#
########################################################################
import os

def checkpkg(context, name):
    context.Message("Checking for {0}...".format(name))
    ret = (context.TryAction("pkg-config --exists '{0}'".format(name)))[0]
    context.Result(ret)
    return ret

env = Environment()
conf = Configure(env, custom_tests = {'checkpkg': checkpkg})

if not conf.checkpkg('libpulse'):
    print ("PulseAudio not found. Check PKG_CONFIG_PATH or installation.")
    Exit(1)

env = conf.Finish()
env.ParseConfig('pkg-config libpulse --cflags --libs')
pavol = env.Program(target = 'opavol', source = ['pavol.c'])


prefix = '/usr/local'
prefix = ARGUMENTS.get('prefix', prefix)
binpath = os.path.join(prefix, 'bin')
env.Install(dir = binpath, source = pavol)
env.Alias('install', [binpath]) 
